<?php

namespace App\Http\Controllers\Web;

use App\Models\PolityAnalysis;
use App\Models\PolityChoices;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class IndexController extends Controller
{
    public function search(Request $request)
    {
        if (!$request->keywords) return back()->with('msg', '请输入要搜索的内容！');
        $polity_choices = PolityChoices::where('title', 'like', '%' . $request->keywords . '%')->get();
        $polity_analysis = PolityAnalysis::where('title', 'like', '%' . $request->keywords . '%')->get();
        return view('web.search', [
            'keywords'=>$request->keywords,
            'polity_choices' => $polity_choices,
            'polity_analysis' => $polity_analysis
        ]);
    }
}
